using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraFocusController : MonoBehaviour
{
    public Transform FocusPoint;
    public PlayerInputController InputController;
    public Transform Player; // 玩家对象

    public float MaxPlayerDistance = 5f; // 最大距离
    public float damping = 0.1f;

    private void Update()
    {
        SetFocusPoint();
    }

    private void SetFocusPoint()
    {
        Vector3 mousePosition = InputController.GetMousePosition();

        // 计算从玩家到鼠标位置的向量
        Vector3 desiredPosition = mousePosition - Player.position;

        // 限制焦点位置在圆内
        desiredPosition = Vector3.ClampMagnitude(desiredPosition, MaxPlayerDistance);

        // 将焦点位置设为玩家位置加上限制后的向量
        Vector3 targetPosition = Player.position + desiredPosition;

        // 平滑过渡到目标位置
        FocusPoint.position = Vector3.Lerp(FocusPoint.position, targetPosition, damping * Time.deltaTime);
    }
}